<?php

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
 */

// Route::middleware('auth:api')->get('/user', function (Request $request) {
//     return $request->user();
// });

// 此文件里面的所有路由都默认添加api前缀

Route::prefix('v1')->group(function () {
    Route::post('admin/login', 'Admin\LoginController@login')->name('登录');
    Route::prefix('admin')->middleware(['checkAdminToken', 'adminLog'])->group(function () {
        // 管理员设置
        Route::get('info', 'Admin\AdminController@info')->name('查看个人信息'); // 信息
        Route::put('password', 'Admin\AdminController@editPassword')->name('修改密码'); //_method=PUT 修改密码
        Route::post('logout', 'Admin\AdminController@logout')->name('登出'); // 退出

        // 角色管理
        Route::get('roles', 'Admin\RoleController@index')->name('查看角色列表');

        // 班级管理
        Route::get('classes', 'Admin\ClassController@index')->name('查看班级列表');
        Route::post('classes', 'Admin\ClassController@create')->name('新增班级');
        Route::put('classes/{id}', 'Admin\ClassController@update')->name('修改班级信息'); //_method=PUT
        Route::delete('classes/{id}', 'Admin\ClassController@destroy')->name('删除班级'); //_method=delete
        Route::delete('classes', 'Admin\ClassController@destroyAll')->name('批量删除班级'); //_method=delete
        // 班级照片
        Route::post('classes/{id}/photos', 'Admin\ClassController@upload')->name('上传班级照片');
        Route::get('classes/{id}/photos', 'Admin\ClassController@photo')->name('查看班级照片');
        Route::post('classes/photos/{id}', 'Admin\ClassController@destroyPhoto')->name('删除班级照片');

        // 员工管理
        Route::get('admins', 'Admin\AdminController@index')->name('查看员工列表');
        Route::post('admins', 'Admin\AdminController@create')->name('新增员工');
        Route::put('admins/{id}', 'Admin\AdminController@update')->name('修改员工信息'); //_method=PUT
        Route::put('admins/{id}/reset', 'Admin\AdminController@resetPassword')->name('重置员工密码'); //_method=PUT 重置密码
        Route::delete('admins/{id}', 'Admin\AdminController@destroy')->name('删除员工'); //_method=delete

        // 学生管理
        Route::get('students', 'Admin\StudentController@index')->name('查看学生信息列表');
        Route::post('students/excel', 'Admin\StudentController@download')->name('下载学生excel');
        Route::put('students/{id}', 'Admin\StudentController@update')->name('修改学生信息'); //_method=PUT
        Route::delete('students/{id}', 'Admin\StudentController@destroy')->name('删除学生'); //_method=delete
        Route::delete('students', 'Admin\StudentController@destroyAll')->name('批量删除学生'); //_method=delete

        // 反馈意见
        Route::get('feedbacks', 'Admin\FeedbackController@index')->name('查看反馈列表');
        Route::get('feedbacks/{id}', 'Admin\FeedbackController@info')->name('查看反馈信息');

        // 学生问题吐槽
        Route::get('questions', 'Admin\StudentQuestionController@index')->name('学生问题列表');
        Route::put('questions/{id}/read', 'Admin\StudentQuestionController@read')->name('问题已读');
        Route::put('questions/readall', 'Admin\StudentQuestionController@readall')->name('问题全部已读');
        Route::delete('questions/{id}', 'Admin\StudentQuestionController@destroy')->name('删除问题');
    });

    Route::prefix('wx')->group(function () {
        Route::get('code2Session', 'Wx\WxController@code2Session')->name('微信小程序opeid');
        Route::get('class/list', 'Wx\StudentController@getClassList')->name('查看可报名班级列表');
        Route::get('student/info', 'Wx\StudentController@info')->name('查看学生信息');
        Route::post('enter', 'Wx\StudentController@enter')->name('新增学生报名');
        Route::get('status', 'Wx\StudentController@status')->name('查看报名状态');
    });

});
